package jwt.duplo.game.core {

	import away3dlite.containers.Scene3D;
	import away3dlite.containers.View3D;
	import away3dlite.core.clip.RectangleClipping;
	import away3dlite.core.render.FastRenderer;
	
	import flash.events.Event;

	
	/**
	 * Base Class for all dupplo 3D games extending GameEngine to tie in with the website. 
	 * @author pwolleb
	 * 
	 */	
	public class GameEngine3D extends GameEngine {
		
		protected var _view:View3D;
		protected var _scene:Scene3D;
		protected var _clipping:RectangleClipping;
		
		public override function startup():void {
			_view = new View3D();
			_view.renderer = new FastRenderer();
			_scene = _view.scene;
			addChild(_view);
		}
		
		public override function shutdown():void {
			super.shutdown();
			removeChild(_view);
			_view.camera = null;
			_view.scene = null;
			_scene = null;
		}
		
		protected override function render(e:Event):void {
			_view.render();	
		}
		
		public override function resize(width:int, height:int):void {
			_view.x = width * .5;
			_view.y = height * .5;
			_view.clipping = new RectangleClipping();
		} 
	}
}